home *** CD-ROM | disk | FTP | other *** search
- // messages to be used by components
- message ShowHint(szx _szText);
- message MoveHint(i32x _posX, i32x _posY);
- message HideHint();
-
- // messages to be used by manager
- //message ResetHint();
- //message HintReset();
- message HintSet(szx _szText);
- message HintReset();
-
- func void Hint_OnLoop(f32x _fDelta);
- func void Hint_Reset();
- func void Hint_Set(szx _szText);
-
- //
- //
- //
- class Gui_dtHint
- {
- var Gui_Component gcBorder;
- var Gui_Component gcBack;
- var Gui_Component gcText;
- var i32x iWidth, iHeight;
- var f32x fTimer;
- var boolx bRunning;
- var szx szText;
- };
-
- class Gui_dtHintTimer
- {
- };
-
- //
- //
- //
- interface Gui_iHint
- {
- Hint_Set HintSet;
- Hint_Reset HintReset;
- }
-
-
- //
- //
- //
- interface Gui_iHintTimer
- {
- Hint_OnLoop Loop;
- }
-
-
- //
- //
- //
- interface Gui_iHintCaption
- {
- }
-
-
- //
- //
- //
- func Gui_Component NewHint()
- {
- var Gui_Component pComposite, pText, pBack, pBorder;
- var Menu_Sprite sprite;
-
- pComposite = NewObject(Gui_iHint);
- var Gui_dtHint pdtHint;
- pdtHint = new Gui_dtHint;
- SetData(pComposite, pdtHint);
-
- // border
- pBorder = NewBitmap(smWhite, 0);
- SetShadingMode(GetSprite(pBorder), DLC_GouraudMode_ModulateDiffuse, DLC_GouraudMode_ModulateDiffuse);
- SetBlendingMode(GetSprite(pBorder), DLC_Blend_AlphaBlend);
- SetAlign(pBorder, e_GUI_HAlign_Zoom, e_GUI_VAlign_Zoom);
- SetColor(pBorder, cHintTextColor);
- MountComponent(pComposite, pBorder);
- pdtHint.gcBorder = pBorder;
-
- // back
- pBack = NewBitmap(smWhite, 0);
- SetShadingMode(GetSprite(pBack), DLC_GouraudMode_ModulateDiffuse, DLC_GouraudMode_ModulateDiffuse);
- SetBlendingMode(GetSprite(pBack), DLC_Blend_AlphaBlend);
- SetAlign(pBack, e_GUI_HAlign_Zoom, e_GUI_VAlign_Zoom);
- SetColor(pBack, cHintBackColor);
- MountComponent(pComposite, pBack);
- pdtHint.gcBack = pBack;
-
- // text
- pText = NewContainer(Gui_iHintCaption);
- sprite = NewSprite2D(pHintFont);
- SetShadingMode(sprite,DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
- // Attach the sprite to this container
- AttachSprite(pText, sprite);
- SetAlign(pText, e_GUI_HAlign_Center, e_GUI_VAlign_Center);
- MountComponent(pComposite, pText);
- SetColor(pText, cHintTextColor);
- pdtHint.gcText = pText;
-
- pdtHint.gcBorder<<Hide();
- pdtHint.gcBack<<Hide();
- pdtHint.gcText<<Hide();
- pComposite<<Disable();
-
- return pComposite;
- }
-
-
- //
- //
- //
- func void Hint_OnLoop(f32x _fDelta)
- {
- var Gui_Component pthis, pcomponent;
- pthis = GetThis();
- var Gui_dtHint pdtData;
- pdtData = GetPrimaryData(pthis);
-
- // increase timer
- pdtData.fTimer = pdtData.fTimer + _fDelta;
-
- if ((pdtData.fTimer > fHintDelay) && (pdtData.bRunning))
- {
- RemoveInterface(pthis);
-
- var i32x i, iNumComponents;
- iNumComponents = GetComponentNumber(pthis);
- i = 0;
- while (i<iNumComponents)
- {
- pcomponent = GetComponent(pthis, i);
- if (pcomponent)
- {
- pcomponent<<Show();
- }
- i = i + 1;
- }
- }
-
- if (!pdtData.bRunning)
- {
- RemoveInterface(pthis);
- }
- }
-
-
- func void Hint_Set(szx _szText)
- {
- var Gui_Component pthis, pcomponent;
- var Menu_Sprite sprite;
- pthis = GetThis();
- var Gui_dtHint pdtHint;
- pdtHint = GetPrimaryData(pthis);
-
- if (!pdtHint.bRunning)
- {
- pdtHint.bRunning = true;
- pdtHint.fTimer = 0.0;
-
- pdtHint.szText = _szText;
-
- sprite = GetSprite(pdtHint.gcText);
- pdtHint.iWidth = PrecalcTextWidth(sprite, pdtHint.szText) + 10;
- pdtHint.iHeight = PrecalcTextHeight(sprite, pdtHint.szText);
- SetText(sprite, pdtHint.szText);
-
- StretchTo(pdtHint.gcBorder, pdtHint.iWidth + 2, pdtHint.iHeight + 2);
-
- StretchTo(pdtHint.gcText, pdtHint.iWidth, pdtHint.iHeight);
- MoveTo(pdtHint.gcText, 1, 1);
-
- StretchTo(pdtHint.gcBack, pdtHint.iWidth, pdtHint.iHeight);
- MoveTo(pdtHint.gcBack, 1, 1);
-
- StretchTo(pthis, pdtHint.iWidth, pdtHint.iHeight);
- }
- }
-
-
-
- func void Hint_Reset()
- {
- var Gui_Component pthis, pcomponent;
- pthis = GetThis();
- var Gui_dtHint pdtHint;
- pdtHint = GetPrimaryData(pthis);
-
- pdtHint.fTimer = 0.0;
- pdtHint.bRunning = false;
- var i32x i, iNumComponents;
- iNumComponents = GetComponentNumber(pthis);
- i = 0;
- while (i<iNumComponents)
- {
- pcomponent = GetComponent(pthis, i);
- if (pcomponent)
- {
- pcomponent<<Hide();
- }
- i = i + 1;
- }
- }